<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
    
    <head>
        <title>
            订单模版导入
        </title>
        <script type="text/javascript">
            function ajaxfindOrdenoSource(item) {
                $.ajax({
                    type: 'post',
                    url: '${ctx}/v2/customers/ajaxfindOrdenoSource',
                    data: 'customerCode=' + item.value,
                    dataType: 'json',
                    success: function(data) {
                        var tempString = "";
                        if (data.status == "1") {
                            $.each(data.content,
                            function(i) {
                                tempString += "<option value=" + data.content[i].ordenoSourceCode + ">" + data.content[i].ordenoSourceName;
                            });
                        } else {
                            alert(data.content);
                        }
                        $("#ordenoSourceCode").html(tempString);
                        $("#ordenoSourceCode").trigger("chosen:updated");
                    },
                    error: function() {
                        alert("获取信息错误！");
                    }
                });
            }
        </script>
    </head>
    
    <body>
        <section class="content">
            <div class="row">
                <c:if test="${not empty message}">
                    <div id="message" class="alert alert-success">
                        <button data-dismiss="alert" class="close">×</button>${message}
                    </div>
                </c:if>
                <div class="col-md-12">
                    <div class="col-sm-4">
                        <div class="input-group col-sm-12">
                            <label class="input-group-text">客户名称:</label>
                            <select class="form-control " onchange="ajaxfindOrdenoSource(this)" id="customers">
							    <c:forEach items="${customers}" var="o">
								    <option value="${o.customerCode}"> ${o.customerName } </option>
							    </c:forEach>
							</select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="input-group col-sm-12 ">
                            <label class="input-group-text ">订单平台:</label>
                            <select class="form-control "" id="ordenoSourceCode">
                                <c:forEach items="${sources}" var="o">
                                    <option value="${o.ordenoSourceCode}">
                                        ${o.ordenoSourceName}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <div id="fullbg"></div>
        <div id="dialog">
            <div>
                <img src="${ctx }/static/022.gif"></img>
            </div>
        </div>
        
        <div class="row">
        	<div class="col-md-12">
	            <form id="form2" method="post" enctype="multipart/form-data">
	                <table class="table table-striped table-bordered table-condensed">
	                    <thead>
	                        <tr bgcolor="#3FA8F3">
	                            <th colspan="14" style="height: 30px; font-size: 18px; color: white; vertical-align: middle;">
	                                商品导入模版设置
	                            </th>
	                            <tr>
	                    </thead>
	                    <tbody>
	                        <tr>
	                            <td>
	                                <input name="file" class="btn" type="file">
	                            </td>
	                        </tr>
	                        <tr>
	                            <td style="height: 50px; vertical-align: middle;">
	                                <button type="submit" class="btn btn-primary" id="skuFormUpload">开始设置</button>
	                                <button type="reset" class="btn">重置</button>
	                            </td>
	                        </tr>
	                    </tbody>
	                </table>
	            </form>
            </div>
            </div>
            
            <div class="row">
	            <div class="col-md-12">
		            <form id="form1" method="post" enctype="multipart/form-data">
		                <table class="table table-striped table-bordered table-condensed">
		                    <thead>
		                        <tr bgcolor="#3FA8F3">
		                            <th colspan="14" style="height: 30px; font-size: 18px; color: white; vertical-align: middle;">
		                                订单数据源模版设置
		                            </th>
		                            <tr>
		                    </thead>
		                    <tbody>
		                        <tr>
		                            <td style="height: 50px; vertical-align: middle;">
		                                <input name="file" class="btn" type="file">
		                            </td>
		                        </tr>
		                        <tr>
		                            <td style="height: 50px; vertical-align: middle;">
		                                <button type="submit" class="btn btn-primary" id="formUpload">开始设置</button>
		                                <button type="reset" class="btn">重置</button>
		                            </td>
		                        </tr>
		                    </tbody>
		                </table>
		            </form>
            </div>
        </div>
        <script type="text/javascript">
            $("#formUpload").click(function() {
                //showBg();
                var erpType = $("#ordenoSourceCode").val();
                var customers = $("#customers").val();
                $("#form1").attr("action", "${ctx}/focusLeadOrdeno/lead/" + customers + "/" + erpType);
            });

            $("#skuFormUpload").click(function() {
                //showBg();
                var customers = $("#customers").val();
                $("#form2").attr("action", "${ctx}/focusLeadOrdeno/lead/" + customers + "/sku");
            });
        </script>
    </body>

</html>